import Vue from "vue";
import VueRouter from "vue-router";

import "../styles/index.less";
const path = require("path");

Vue.use(VueRouter);

const routes = [
    { path: "/", redirect: "/login" },
    {
        path: "/login",
        name: "Login",
        component: () =>
            import ("../views/login"),
    },
    {
        path: "/home",
        name: "Home",
        component: () =>
            import ("../views/home"),
        redirect: "/dashboard",
        children: [
            // 面板
            {
                path: "/dashboard",
                meta: { title: "面板" },
                name: "BashboardIndex",
                component: () =>
                    import ("../views/dashboard/index"),
            },
            // 后台管理
            {
                path: "/base",
                name: "base",
                meta: { title: "后台管理" },
                component: () =>
                    import ("@/views/base"),
                children: [{
                        path: "/base/users",
                        meta: { title: "用户" },
                        name: "BaseUsersIndex",
                        component: () =>
                            import ("../views/base/user"),
                    },
                    {
                        path: "/base/menus",
                        meta: { title: "菜单" },
                        name: "BaseMenusIndex",
                    },
                    {
                        path: "/base/permissions",
                        meta: { title: "权限" },
                        name: "BasePermissionsIndex",
                        component: () =>
                            import ("../views/base/permission"),
                    },
                    {
                        path: "/base/logs",
                        meta: { title: "日志" },
                        name: "BaseLogsIndex",
                        component: () =>
                            import ("../views/base/logs"),
                    },
                ],
            },
            // 企业管理
            {
                path: "/companys/list",
                meta: { title: "企业管理" },
                name: "CompanysIndex",
            },
            // 题库管理
            {
                path: "/questions",
                name: "questions",
                meta: { title: "题库管理" },
                component: () =>
                    import ("@/views/questions"),
                children: [{
                        path: "/questions/list",
                        meta: { title: "基础题库" },
                        name: "",
                        component: () =>
                            import ("../views/questions/list"),
                    },
                    { path: "/questions/choice", meta: { title: "精选题库" }, name: "" },
                    { path: "/questions/new", meta: { title: "试题录入" }, name: "" },
                    { path: "/questions/randoms", meta: { title: "组题列表" }, name: "" },
                ],
            },
            // 学科管理
            {
                path: "/subjects",
                meta: { title: "学科管理" },
                name: "subjects",
                children: [
                    { path: "/subjects/list", meta: { title: "学科" }, name: "" },
                    { path: "/subjects/directorys", meta: { title: "目录" }, name: "" },
                    { path: "/subjects/tags", meta: { title: "标签" }, name: "" },
                ],
            },

            // 面试技巧
            {
                path: "/articles/list",
                meta: { title: "面试技巧" },
                name: "ArticlesIndex",
                component: () =>
                    import ("../views/article-list"),

            },
        ],
    },
];

const router = new VueRouter({
    routes,
});

export default router;